var newheader = `

<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>京西商城</title>
	<link rel="stylesheet" type="text/css" href="style/search.css">
	<link rel="stylesheet" type="text/css" href="style/global.css">
	<link rel="stylesheet" href="style/layui.css">
	<script src="js/seaarch.js"></script>
	<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
	<script type="text/javascript" src="js/header.js"></script>
	<script src="js/layui.js"></script>
	<script src="js/layui.all.js"></script>
</head>

<body>

	<div id="top">
		<div id="top_main">
			<ul class="topu">
				<li class="xuan">
					<div class="erwei"></div>
					<a href="" class="aa">关注恒之
						<!-- 将二维图添加进a标签里 -->
						<div class="erweitu"></div>
					</a>
				</li>
			</ul>
			<div id="hello">
				<span>您好，欢迎来到恒之！
					<a href="login.html" id="pleaselogin" style="color:#d8131c">[ 登陆 ]</a>
					<a href="regist.html" id="regin">[ 免费注册 ]</a>
				</span>
			</div>
			<div class="topright">
				<ul>
					<li>
						<div class="cun">
							<a href="order.html">我的订单</a>
						</div>
					</li>
					<li class="hidetu">
						<div class="cun">
							<a href="" class="dong">手机恒之</a>
						</div>
					</li>
					<li class="kefu">
						<div class="cun">
							<div class="a1">
								<div class="kefuhide">
									<span>客户服务</span>
									<div class="downjian1"></div>
									<ul>
										<li><a href="">帮助中心</a></li>
										<li><a href="">售后服务</a></li>
										<li><a href="">在线客服</a></li>
										<li><a href="">投诉中心</a></li>
										<li><a href="">客服邮箱</a></li>
									</ul>

								</div>

							</div>

						</div>

					</li>

					<li class="wangzhan">

						<div class="cun">

							<span>网站导航</span>

							<div class="downjian1"></div>

						</div>

						<div class="wangzhanhide">

							<div class="tese"><span>特色栏目</span></div>

							<div class="tesemain">
								<a href="http://www.ayvvv.com">恒之官网</a>
							</div>

							<div class="tese"><span>企业服务</span></div>

							<div class="tesemain1">
								<a href="http://www.ayvvv.com">恒之官网</a>
							</div>
							<div class="tese"><span>旗下网站</span></div>
							<div class="tesemain2">
								<a href="http://www.ayvvv.com">恒之官网</a>
							</div>
						</div>
					</li>
				</ul>
			</div>
		</div>
	</div>
	<!-- 搜索区域开始 -->
	<div id="serach">

		<div class="logo">

			<a href="index.html"><img src="images/hz.png" style="width: 45%;" alt="" /></a>

			

		</div>

		<div class="sou">

			<div class="sousuo">
				<!-- <input type="text" class="kuang" placeholder="请输入内容" style="color:#999;font-size:14px" /> -->
				<!-- <div class="souzi"><a href="">搜索</a></div> -->
				<input type="text" id="txxt" class="kuang" placeholder="请输入商品关键字" style="color:#999;font-size:14px" />
				<input type="button" class="souzi" value="搜索" id="BtnSearch"
					style="  border:0;outline: none; color: aliceblue;" />
			</div>
			<div class="reci">
				<!-- <span>热门搜索:</span> -->
			</div>

		</div>

		<div class="myjd">

			<div class="mytu"></div>

			<a href="#">我的恒之</a>

			<div class="jiantou"></div>
			<div class="myjdhide">

				<div class="hello">

					<span>您好，请</span>

					<a href="" id="logout">退出</a>

				</div>

				<div class="hey">

					<div class="heyleft">
						<ul>
							<li><a href="order.html">待处理订单</a></li>
							<li><a href="">咨询回复</a></li>
							<li><a href="">返修退换货</a></li>
							<li><a href="">优惠券</a></li>
						</ul>
					</div>
					<div class="heyright">

						<ul>

							<li><a href="">我的关注></a></li>

							<li><a href="">我的恒之></a></li>
						</ul>

					</div>


				</div>
			</div>
		</div>
		<div class="gouwuche">
			<div class="chetu"></div>
			<a href="flow1.html">去购物车结算</a>
			<div class="jianleft"></div>
			<div class="num">
				<div class="numright"></div>
				<div class="numzi">
					 <span id="shopp">0</span> 
				</div>
			</div>
		</div>
	</div>
	<!-- 搜索区域结束 -->

	<!-- 导航条区域开始 -->
	<div id="daohang">
		<div class="dhleft">
			<a href="list.html">全部商品分类</a>
		</div>
		<div class="dhright">
			<ul>
				<li><a href="list.html" style="background: #A40000">首页</a></li>
				<li><a href="list.html">电脑器材店</a></li>
				<li><a href="list.html">得力办公</a></li>
				<li><a href="list.html">齐心办公</a></li>
				<li><a href="list.html">打印机耗材</a></li>
				<li><a href="list.html">办公用品</a></li>
				<li><a href="list.html">办公百货</a></li>
				<li><a href="list.htmls">教育培训</a></li>
			</ul>
		</div>
	</div>

	<!-- 导航条区域结束 -->
	<div style="clear:both;"></div>
	<script>
		$('#BtnSearch').click(function () {
			let keyword = $('#txxt').val();
			handle(keyword);
		});
		document.onkeydown = keyDownSearch;
		function keyDownSearch(e) {
			var theEvent = e || window.event;
			var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
			if (code == 13) {
				let keyword = $('#txxt').val();
				handle(keyword);
				return false;
			}
			return true;
		}


		var serCmsData = localStorage.getItem('token');
		var url = 'http://hengzhi.ayvvv.com';
		$.ajax({
			url: 'http://hengzhi.ayvvv.com/api/user',
			dataType: 'json',
			type: 'get',
			async: true,
			headers: {
				"x-token": serCmsData
			},
			success: function (data) {
				if (data.status == 200) {
					$('#pleaselogin').text(data.data.nickname);
					$('#regin').hide();
				} else {
				}
			}
		});

		$("#logout").click(function () {
			$.ajax({
				url: url + '/api/logout',
				dataType: 'json',
				type: 'post',
				async: true,
				headers: {
					"x-token": serCmsData
				},
				success: function (data) {
					alert(111)
					if (data.status == 200) {
						localStorage.clear();
						alert(111)
					}
				}
			});
		})

	</script>
</body>

`
$('#newheader').after(newheader);

$('.txt').click(function () {
	window.location.href = 'headerrr.html';
})
var serCmsData = localStorage.getItem('token');
var url = 'http://hengzhi.ayvvv.com';
$.ajax({
	url: url + '/api/user/cart/count',
	type: 'get',
	dataType: 'json',
	async: true,
	headers: {
		"x-token": serCmsData
	},
	success: function (data) {

		if (data.status == 200) {
			for (var a = 0; a < data.data.length; a++) {
				$('#shopp').hide();
				$('.numzi').append(`<span id="shopp">` + data.data[a].count + `</span>
		   `)
			}
		} else {
		}
	}
});


